{% extends 'ComptaFormsBundle::layout.html.twig' %}

{% block content %}
<h1>Transaction list</h1>

<p>
    Aller à la page : 
</p>
<ul class="pager">
    {% set skip=false %}
    {% for i in 1..maxPages %}
        {% if i in [1,2,currentPage-1,currentPage,currentPage+1,maxPages-1,maxPages] %}
            {% set skip=false %}
            <li><a href="{{ path('transaction',  {'page':i}) }}">
                {% if i == currentPage %}
                    <b>{{i}}</b>
                {%else%}
                    {{i}}
                {%endif%}
            </a></li>
        {%else%}
            {% if skip != true %}
                <li>...</li>
                {% set skip=true %}
            {%endif%}
        {%endif%}
    {% endfor %}
</ul>
<table class="records_list">
    <thead>
        <tr>
            <th>Catégorie</th>
            <th>Prix</th>
            <th>Description</th>
            <th>Date</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
            {% for entity in entities %}
            <tr>
                <td>{{ entity.category }}</td>
                <td>{{ entity.price }}</td>
                <td>{{ entity.description }}</td>
                <td>{% if entity.date %}{{ entity.date|date('d/m/Y') }}{% endif%}</td>
                <td>
                    <ul>
                        <li>
                            <a href="{{ path('transaction_show', { 'id': entity.id }) }}">show</a>
                        </li>
                        <li>
                            <a href="{{ path('transaction_edit', { 'id': entity.id }) }}">edit</a>
                        </li>
                    </ul>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <ul>
        <li>
            <a href="{{ path('transaction_new') }}">
                Nouvelle transaction
            </a>
        </li>
    </ul>
 {% endblock %}